#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "List.h"

typedef struct {
	int a;
	int b;
} Element;

int main(){
	List* list;
	ListIterator* it;
	void* nextperso;
	
	printf(">>>>list = createList(5)\n");
	list = newList(5);
	assert(listIsEmpty(list) == 1);
	
	listDebug(list);
	
	/*
	printf(">>>>listInsertFirst(list,&elms[0])\n");
	listInsertFirst(list,&elms[0]);
	assert(listIsEmpty(list) == 0);
	assert(listGetSize(list) == 1);
	
	listDebug(list);
	
	printf(">>>>listInsertFirst(list,&elms[1])\n");
	listInsertFirst(list,&elms[1]);
	assert(listGetSize(list) == 2);
	
	listDebug(list);
	
	assert(listGetAt(list,5) == NULL);
	assert(listGetFirst(list) == &elms[1]);
	assert(listGetLast(list) == &elms[0]);
	
	for(i = 2; i < 16 ; i++){
		printf(">>>>listInsertFirst(%.8X)\n",&elms[i]);
		listInsertFirst(list,&elms[i]);
		listDebug(list);
	}
	
	assert(listGetSize(list) == 16);
	assert(listGetAt(list,7) == &elms[15-7]);
	assert(listGetAt(list,8) == &elms[15-8]);
	*/
	
	printf(">>>>listInsertFirst(%.8X)\n",0x11111111);
	listInsertFirst(list,(void*)0x11111111);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x22222222);
	listInsertFirst(list,(void*)0x22222222);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x33333333);
	listInsertFirst(list,(void*)0x33333333);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x44444444);
	listInsertFirst(list,(void*)0x44444444);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x55555555);
	listInsertFirst(list,(void*)0x55555555);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x66666666);
	listInsertFirst(list,(void*)0x6666666);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x77777777);
	listInsertFirst(list,(void*)0x77777777);
	listDebug(list);
	
	printf(">>>>listInsertFirst(%.8X)\n",0x88888888);
	listInsertFirst(list,(void*)0x88888888);
	listDebug(list);
	
	
	printf(">>>>listInsertLast(%.8X)\n",0x11111111);
	listInsertLast(list,(void*)0x11111111);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x22222222);
	listInsertLast(list,(void*)0x22222222);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x33333333);
	listInsertLast(list,(void*)0x33333333);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x44444444);
	listInsertLast(list,(void*)0x44444444);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x55555555);
	listInsertLast(list,(void*)0x55555555);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x66666666);
	listInsertLast(list,(void*)0x6666666);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x77777777);
	listInsertLast(list,(void*)0x77777777);
	listDebug(list);
	
	printf(">>>>listInsertLast(%.8X)\n",0x88888888);
	listInsertLast(list,(void*)0x88888888);
	listDebug(list);
	/*
	for(i = 0; i < 17; i++){
		printf("************ rem %d\n",i);
		printf("************ Removed : %.8X\n",listRemLast(list));
		printf("************ rem %d OK\n",i);
		listDebug(list);
	}
	*/
	
	/*for(i = 2; i < 16 ; i++){
		printf(">>>>listInsertLast(%.8X)\n",&elms[i]);
		listInsertLast(list,&elms[i);
		listDebug(list);
	}*/
	
	listForEach(nextperso,list){
		printf("next : %.8X\n",(unsigned int)nextperso);
	}
	
	it = newListIt(list);
	listItForEach(nextperso,it){
		printf("next IT : %.8X\n",(unsigned int)nextperso);
	}

	for(nextperso = listItGetPrev(it);nextperso != NULL;nextperso = listItGetPrev(it)){
		printf("prev IT : %.8X\n",(unsigned int)nextperso);
	}
	deleteListIt(it);
	
	return 0;
}
